<template>
<div>
  <h1>教师表</h1>
  <table border="1" align="center" cellspacing="0">
    <tr>点击教师姓名,查看该教师的所以学生</tr>
    <tr>
      <td>id</td>
      <td><span @click="btn2()">教师姓名</span></td>
      <td>性别</td>
      <td>操作</td>
    </tr>
    <tr v-for="i in data">
      <td>{{i.id}}</td>
      <td>{{i.name}}</td>
      <td>{{i.gender}}</td>
      <td><button>离职</button></td>
    </tr>
  </table>
</div>
</template>

<script>
export default {
name: "teachers",
  data(){
  return{
    data:""
  }
  },
  methods:{
  btn1(){
    this.axios.get('tea/').then(
      res=>{
        this.data=res.data
          console.log(res)
      }
    )
  },
    btn2(id){
    this.$router.push({path:'students/',query:{id:id}})
    }
  },

  mounted() {
  this.btn1()
  }
}
</script>

<style scoped>

</style>
